package com.graduation.smartparkingplatform.Config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

  @Value("${image.carPlatePath}")
  private String carPlatePath;

  @Value("${image.opinionPath}")
  private String opinionPath;

  @Value("${image.carPlateIn}")
  private String carPlateInPath;

  @Value("${image.carPlateOut}")
  private String carPlateOutPath;

  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/image/CarPlate/**").addResourceLocations("file:" + carPlatePath);
    registry.addResourceHandler("/image/Opinion/**").addResourceLocations("file:" + opinionPath);
    registry
        .addResourceHandler("/image/CarPlateIn/**")
        .addResourceLocations("file:" + carPlateInPath);
    registry
        .addResourceHandler("/image/CarPlateOut/**")
        .addResourceLocations("file:" + carPlateOutPath);
  }
}
